/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.iddaa.core.dao.impl;

import com.iddaa.core.dao.LeagueDAO;
import com.iddaa.core.domain.League;
import org.hibernate.criterion.DetachedCriteria;
import org.hibernate.criterion.Restrictions;
import org.springframework.dao.support.DataAccessUtils;
import org.springframework.stereotype.Repository;

/**
 *
 * @author aziz
 */
@Repository("leageuDao")
public class LeagueDAOImpl extends AbstractHibernateDAO<League, Long> implements LeagueDAO {

    @SuppressWarnings("unchecked")
	@Override
    public League findByName(String name) {
        DetachedCriteria criteria = DetachedCriteria.forClass(persistentClass);
        criteria.add(Restrictions.eq("name", name));
        return (League) DataAccessUtils.singleResult(hibernateTemplate.findByCriteria(criteria));
    }
}
